home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9030 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.wyoming.com!usenet
  2. From: dcromley@wyoming.com (Dave Cromley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Class problem
  5. Date: 28 Feb 1996 04:02:33 GMT
  6. Organization: wyoming.com LLC
  7. Message-ID: <4h0k4p$isp@horn.wyoming.com>
  8. References: <4gv6j2$klv@news-e2b.gnn.com>
  9. NNTP-Posting-Host: cys-cap-9.wyoming.com
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.99.2
  12.  
  13. Pam wrote:
  14. >..I use Borland C++ ver. 3.1.  It keeps giving me an error saying 
  15. "Illegal Structure Operation" on these two lines:
  16. >                  cin >> addr.zip;
  17. >                  cin >> addr.phone;
  18. >
  19. >Both of these fields are listed within my address class.  I have it 
  20. >listed as:
  21. >                class addr_data:public name_data
  22. >                {
  23. >                 public:
  24. >                     char street[25];
  25. >                     char city[15];
  26. >                     char state[3];
  27. >                     int zip[11];
  28. >                     int phone[10];
  29. >                 }addr;
  30.  
  31. My Borland C++4.5 doesn't give that, but still, I don't think this 
  32. is what you want. 
  33. 'char street[25]' defines an array of 25 characters, a string that
  34. is what you want.
  35. 'int zip[11]' ddefines an array of 11 integers, which isn't what 
  36. you want.
  37. If an int could hold 11 digits, then it would be 'int zip'.
  38. Even a long int won't hold that.
  39. So you probably want 'char zip[11]'.
  40.  
  41.   Dave C.
  42.  
  43.